package com.lcl.jarvis.service.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.lcl.jarvis.dto.DoctorsQueryDTO;
import com.lcl.jarvis.dto.DoctorsDTO;
import com.lcl.jarvis.bo.DoctorsBO;
import com.lcl.jarvis.service.DoctorsService;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author licl
 * @since 2024-05-16
 */
@Service
public class DoctorsServiceImpl implements DoctorsService {


    private final DoctorsBO doctorsBO;

    @Autowired
    public DoctorsServiceImpl(DoctorsBO doctorsBO){
        this.doctorsBO = doctorsBO;
    }

    /**
     * 简单分页查询
     *
     * @param pageNumber 页码
     * @param pageSize 每页数量
     * @param sort 正序/倒序
     * @param order 排序字段-属性名
     * @param doctors
     * @return
     */
    @Override
	public Map<String, Object> queryPage(DoctorsQueryDTO doctors) {
    	return doctorsBO.queryByDTOPage(doctors);
	}

    /**
     * 查询所有信息
     *
     * @param doctors 参数 DoctorsQueryDTO 对象
     * @return 对象List
     */
    @Override
    public List<DoctorsDTO> queryAll(DoctorsQueryDTO doctors) {
        return doctorsBO.queryByDTO(doctors);
    }

    /**
     * 通过ID查询
     *
     * @param id ID
     * @return Doctors
     */
    @Override
    public DoctorsDTO queryById(String id) {
        return doctorsBO.getById(id);
    }


    /**
     * 添加
     *
     * @param doctors DTO
     * @return DoctorsDTO
     */
    @Override
    public DoctorsDTO save(DoctorsDTO doctors) {
        doctors.setCreateTime(new Date());
        return doctorsBO.save(doctors);
    }

    /**
     * 更新
     *
     * @param doctors DTO
     * @return DoctorsDTO
     */
    @Override
    public DoctorsDTO update(DoctorsDTO doctors) {
        return doctorsBO.updateById(doctors);
    }

    /**
     * 删除
     *
     * @param id 主键
     */
    @Override
    public void delete(String id) {
        doctorsBO.delete(id);
    }
}
